package es.mfp.practicos.view;

import java.util.List;

import javax.faces.event.ActionEvent;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import es.mfp.practicos.domain.Factura;
import es.mfp.practicos.service.FacturasService;

@Component("verFacturas")
@Scope("request")
public class VerFacturas {

	private FacturasService facturaService;

	@Autowired
	public VerFacturas(FacturasService facturaService) {
		this.facturaService = facturaService;
	}

	private List<Factura> facturas;

	private Factura factura;

	public List<Factura> getFacturas() {
		return facturas;
	}

	public void setFacturas(List<Factura> facturas) {
		this.facturas = facturas;
	}

	public void buscar(ActionEvent event) {
		this.facturas = facturaService.getFacturas();
		this.factura = facturas.get(0);
	}

	public Factura getFactura() {
		return factura;
	}

	public void setFactura(Factura factura) {
		this.factura = factura;
	}
}
